package com.xbongbong.paas.model.impl;

import com.xbongbong.paas.domain.dao.BusinessRuleLogDao;
import com.xbongbong.paas.domain.entity.BusinessRuleLogEntity;
import com.xbongbong.paas.model.BusinessRuleLogModel;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.util.DateTimeUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author 吴峰
 * @version v1.0
 * @date 2020/5/9 19:48
 * @since v1.0
 */
@Service("businessRuleLogModel")
public class BusinessRuleLogModelImpl implements BusinessRuleLogModel {

    @Resource
    private BusinessRuleLogDao businessRuleLogDao;

    @Override
    public Integer insert(BusinessRuleLogEntity entity) {
        long now = DateTimeUtil.getInt();
        entity.setAddTime(now);
        entity.setUpdateTime(now);
        return businessRuleLogDao.insert(entity);
    }

    @Override
    public Integer update(BusinessRuleLogEntity entity) throws XbbException {
        long now = DateTimeUtil.getInt();
        entity.setUpdateTime(now);
        return businessRuleLogDao.update(entity);
    }

    @Override
    public List<BusinessRuleLogEntity> findEntitys(Map<String, Object> param) {
        return businessRuleLogDao.findEntitys(param);
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> param) {
        return businessRuleLogDao.getEntitysCount(param);
    }

    @Override
    public List findEntitysWithoutSub(Map<String, Object> param) {
        return null;
    }

    @Override
    public Integer delete(String corpid, Long id) {
        return businessRuleLogDao.deleteByKey(id, corpid);
    }
}
